package com.aurora.gulimall.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


public class OrderConfirmVo {
    //收货地址
    @Setter @Getter
    private List<MemberAddressVo> address;

    //所有选中的购物项
    @Setter @Getter

    private List<OrderItemVo> items;

    //优惠券信息 积分
    @Setter @Getter
    private Integer integration;
//    private BigDecimal payPrice;//实际应付价格


    @Setter @Getter
    private String orderToken;//防重令牌
    @Setter @Getter
    private Map<Long,Boolean> stocks;

    public BigDecimal getTotal(){
        BigDecimal sum = new BigDecimal("0");
        if(items != null){
            for (OrderItemVo item : items) {
                sum = sum.add(item.getPrice().multiply(new BigDecimal(item.getCount())));
            }
        }
        return sum;
    }
    public Integer getCount(){
        Integer i = 0;
        if(items != null){
            for (OrderItemVo item : items) {
                i += item.getCount();
            }
        }
        return i;
    }


    public BigDecimal getPayPrice(){
        return getTotal();
    }



}
